import request from '@/utils/request'

export type LeaveVO = {
  id: number
  status: number
  type: number
  reason: string
  attachments: string
  processInstanceId: string
  startTime: string|number
  endTime: string|number
  createTime: string
  startUserSelectAssignees: any
  [key: string]: any;
}

// 创建请假申请
export const createLeave = async (data: LeaveVO) => {
  return await request.post({ url: '/bpm/oa/leave/create', data: data })
}
// 更新请假申请
export const updateLeave = async (data: LeaveVO) => {
  return await request.put({ url: '/bpm/oa/leave/update', data: data })
}

// 获得请假申请
export const getLeave = async (id: number) => {
  return await request.get({ url: '/bpm/oa/leave/get?id=' + id })
}

// 获得请假申请分页
export const getLeavePage = async (params: any) => {
  return await request.get({ url: '/bpm/oa/leave/page', params })
}

// 发起销假流程 - 请销假专用
export const startCancelLeaveProcess = (data: any): Promise<string> => {
  return request.post({ url: '/bpm/oa/leave/cancel', data })
}
